import {req_delete, req_get, req_post, req_put} from "@/request/cssdrequest";
import {R} from "@/type/dto/R";
import {RP} from "@/type/dto/RP";
import {UserQueryDto} from "@/type/dto/UserQueryDto";
import {UserInfoVO} from "@/type/vo/UserInfoVO";

export async function api_getListUser(userQueryDto: UserQueryDto) {

    const data = await req_get('/user', userQueryDto);
    //转成我要的json
    console.log('data:', data);
    return  JSON.parse(data) as Partial<R<RP<UserInfoVO>>>;
}

export async function api_addUser(userInfo: UserInfoVO) {

    const data = await req_post('/user', userInfo);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

export async function api_deleteUser(userId: string) {

    const data = await req_delete('/user', {id: userId});
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}


export async function api_editUser(userInfo: UserInfoVO) {

    const data = await req_put('/user', userInfo);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}